﻿using Ef.Sqlite;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;

namespace Tpl.EfMigration
{
    public class SDbContextBuilder : IDesignTimeDbContextFactory<SDbContext>
    {
        public SDbContext CreateDbContext(string[] args)
        {
            // 此处写死，简单一点，读取配置文件比较复杂，只是为了迁移数据库
            string connStr = "D:\\blazor.db";
            DbContextOptionsBuilder<SDbContext> builder = new();
            builder.UseSqlite(connStr, b => b.MigrationsAssembly("MigrationClient"));


            var ctx = new SDbContext(builder.Options);

            return ctx;
        }
    }
}
